﻿using Abp.Domain.Entities;
using System;
using System.Collections.Generic;

namespace Laboratory.Entities.User
{
    /// <summary>
    /// 角色
    /// </summary>
    public sealed class Role : Entity<Guid>
    {
        /// <summary>
        /// 角色名称
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int Sort { get; private set; }

        /// <summary>
        /// 添加时间
        /// </summary>
        public DateTime AddTime { get; private set; }

        /// <summary>
        /// 导航属性 - 账号集合
        /// </summary>
        public ICollection<Account>  Accounts { get; private set; }



        /// <summary>
        /// 私有构造器 - EF用
        /// </summary>
        private Role()
        {
            this.Accounts = new HashSet<Account>();
        }

        /// <summary>
        /// 创建构造器
        /// </summary>
        /// <param name="name">角色名称</param>
        /// <param name="sort">排序</param>
        public Role(string name, int sort):this()
        {
            this.Id = Guid.NewGuid();
            this.Name = name;
            this.Sort = sort;
            this.AddTime = DateTime.Now;
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="name">角色名称</param>
        /// <param name="sort">排序</param>
        public void Update(string name, int sort)
        {
            this.Name = name;
            this.Sort = sort;
        }


    }
}
